﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MdcItss.aspx.cs" Inherits="H2.NET.Web.Pages.SMD.MdcItss" %>

<%@ Register src="../../Controls/DwzAssessment.ascx" tagname="DwzAssessment" tagprefix="uc" %>
<%@ Register src="../../Controls/DwzAssessmentList.ascx" tagname="DwzAssessmentList" tagprefix="uc" %>
<%@ Register src="../../Controls/AjaxUpload.ascx" tagname="ajaxUpload" tagprefix="uc" %>
<%@ Register src="uc_store_info.ascx" tagname="uc_store_info" tagprefix="uc" %>
<%@ Register src="uc_head.ascx" tagname="uc_head" tagprefix="uc1" %>
<%@ Register src="../../UserControls/Toolbar.ascx" tagname="Toolbar" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
<head id="Head1" runat="server">
    <title>Mdc Itss</title>
    <link href="<%=Page.ResolveUrl("~/Resource/Css/Style.css")%>" type="text/css" rel="stylesheet" />
    <link href="<%=Page.ResolveUrl("~/Resource/jBox/Blue/jbox.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=Page.ResolveUrl("~/Resource/Css/validform.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=Page.ResolveUrl("~/Resource/qtip/jquery.qtip.min.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=Page.ResolveUrl("~/Resource/select2/select2.css")%>" rel="stylesheet" type="text/css" media="screen" />

    <script src="<%=Page.ResolveUrl("~/Resource/dwz/js/jquery-1.7.2.min.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/Js/Common.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/Js/jquery.money.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/jBox/jquery.jBox-2.3.min.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/jBox/jquery.jBox-zh-CN.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/Js/Validform_v5.3.2.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/My97DatePicker/WdatePicker.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/qtip/jquery.qtip.min.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/select2/select2.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/Js/custom-ui.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/dwz/js/dwz.min.js")%>" type="text/javascript"></script>

    
    <style type="text/css">
        .htable td a{display:inline}
    </style>
    <script type="text/javascript">
        var step = "<%=TaskAPI.Step%>";
        $(function () {

            $(".recipient").InitSelect2("请选择业务流程号", "<%= Page.ResolveUrl("~/Pages/SMD/AjaxTools/Handler.ashx?action=SearchBusinessKey")%>", "name", initprocess, false, "2");
            /* 初始化相关样式、表单验证提示 st */
            $("[datatype='*']").after("<em class='required'>*</em>");
            $("#form1").Validform({
                tipSweep: true,
                tiptype: function(msg, o, cssctl) {
                    if (o.type == 3) {
                        $.jBox.tip(msg, 'info');
                    }
                }
            });
            /* 初始化相关样式、表单验证提示 ed */
            
            <%if(TaskAPI.Step == "Start Apply" && !TaskAPI.Summary.Contains("退回")){ %>
            $("#abortProcess").hide();
            $("#changeDeposit").hide();
            <% }else{ %>
            if (($("#l_businesskey").text() || "") !== "" || $("#businesskey").val() !== "") {

                initprocess($("#l_businesskey").text() || $("#businesskey").val()||"", null);
            }
            var dealercode = $("#l_dealercode").text() || "";
            var authid = $("#l_authid").text() || "";
            var fullsetsn = $("#l_fullsetsn").text() || "";
            if (dealercode !== "" && authid !== "" && fullsetsn !== "") {
                GetDeviceInfo(dealercode, authid, fullsetsn);
            }
            <%}%>
            
            selectType("流程驳回");//默认进入就是驳回流程
        });

        function initprocess(id,dt) {
            $.ajax({
                url: "<%= Page.ResolveUrl("~/Pages/SMD/AjaxTools/Handler.ashx?action=GetBusinessKey")%>",
                data: {businesskey:id},
                success: function (json) {
                    var obj = eval('(' + json + ')');
                    var ss = "";
                    if (obj.length > 0) {
                        for (var i = 0; i < obj.length; i++) {
                            ss += "<tr>" +
                                    "<td> <img border=\"0\" src=\"../../Resource/Images/"+obj[i].imgstatus+"\" style=\"width:16px;height:16px\" /></td>" +
                                    "<td><a onclick='return winOpenForm(\"\/pages\/smd\/taskview.aspx?TaskID=" + obj[i].taskid + "\",\"tr_row_"+obj[i].taskid+"\");'>" + obj[i].processcn + "</a></td>" +
                                    "<td>" + obj[i].stepcn + "</td>" +
                                    "<td>" + obj[i].summary + "</td>" +
                                    "<td>" + obj[i].starttime1 + "</td>" +
                                    "<td>" + (obj[i].FULLNAME||"") + "</td>" +
                                    "<td>" + obj[i].incident + "</td>" +
                                "</tr>";
                        }
                    }
                    $("#tbbusinesskey").html(ss);
                }
            });
        }

        function showDeposit() {
            var dealercode = $("#dealercode").val() || "";
            var authid = $("#authid").val() || "";
            var fullsetsn = $("#fullsetsn").val() || "";
            if (dealercode !== "" && authid !== "" && fullsetsn !== "") {
                GetDeviceInfo(dealercode, authid, fullsetsn);
            }

        }

        function GetDeviceInfo(dealercode,authid,fullsetsn) {
            $.ajax({
                url: "<%= Page.ResolveUrl("~/Pages/SMD/AjaxTools/Handler.ashx?action=GetFullsetDeposit")%>",
                data: {
                    dealercode: dealercode,
                    authid: authid,
                    fullsetsn: fullsetsn
                },
                success: function (json) {
                    var obj = eval('(' + json + ')');
                    var ss = "";
                    var bs = "";
                    if (obj.length > 0) {
                        if (obj[0].dealercode != null) {
                            for (var i = 0; i < 1; i++) {
                                ss += "<tr>" +
                                    "<td>" + obj[i].dealercode + "</td>" +
                                    "<td>" + obj[i].authid + "</td>" +
                                    "<td>" + obj[i].fullsetsn + "</td>" +
                                    "<td>" + obj[i].amount + "</td>" +
                                    "</tr>";
                            }

                            <%if(TaskAPI.Step == "Start Apply" && !TaskAPI.Summary.Contains("退回")){%>
                                $("#olddeposit").text(obj[0].amount);
                                $("#h_olddeposit").val(obj[0].amount);
                            <%}%>
                        }
                        if (obj[0].business != null) {
                            for (var j = 0; j < obj[0].business.length; j++) {
                                bs += "<tr>" +
                                    "<td align='center'><a onclick='return winOpenForm(\"\/pages\/smd\/taskview.aspx?TaskID=" + obj[0].business[j].taskid + "\",\"tr_row_" + obj[0].business[j].taskid + "\");''><img border='0' src='../../Resource/Images/frm_inbox_monitor.gif' style=\"width:22px;height:22px\"></a></td>" +
                                    "<td align='center'>流转中</td>" +
                                    "<td>" + obj[0].business[j].businesskey + "</td>" +
                                    "<td>" + obj[0].business[j].summary + "</td>" +
                                    "</tr>";
                            }
                        }
                    } else {
                        $("#olddeposit").text(0);
                        $("#h_olddeposit").val(0);
                    }
                    $("#tbdepositInfo").html(ss);
                    $("#tbbsInfo").html(bs);
                }
            });
        }


        function selectType(value) {
            $("#changeDeposit").find("input").removeAttr("datatype");
            $("#abortProcess").find("input").removeAttr("datatype");
            switch (value) {
                case "流程驳回":
                    $("#abortProcess").find("input").not(".select2-input").attr("datatype", "*");
                    $("#abortProcess").show();
                    $("#changeDeposit").hide();
                    break;
                case "保证金调整":
                    $("#changeDeposit").find("input").attr("datatype", "*");
                    $("#abortProcess").hide();
                    $("#changeDeposit").show();
                    break;
                default:
                    $("#abortProcess").hide();
                    $("#changeDeposit").hide();
                    break;
            }
        }

        /* 提交表单 st */
        function confirmSubmit() {

            if (window.confirm("确认要提交吗？")) {
                $.jBox.tip('正在处理，请稍等...', 'loading');
                return true;
            }
            return false;
        }
        /* 提交表单 ed */

        function winOpenForm(strURL, id) {
            //document.getElementById(id).style.display = "none";
            var sheight = screen.height - 150;
            var swidth = screen.width - 10;
            var winoption = "left=0,top=0,height=" + sheight + ",width=" + swidth + ",toolbar=yes,menubar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes";
            var tmp = window.open(strURL, '', winoption);
            return false;
        }
    </script>
</head>
<body>
    <div class="flowpage">
    <form id="form1" runat="server">
        <uc1:uc_head ID="uc_head1" runat="server" />
        <asp:HiddenField ID="hf_return_url" runat="server" />
        <asp:HiddenField ID="hf_out_storeId" runat="server" />
        <asp:HiddenField ID="hf_in_storeId" runat="server" />


        <table class="formTable"> 
            <tbody>
                <tr>
                    <th style="width:15%">申请类型：</th>
                    <td style="width:35%">
                      <%--  <asp:DropDownList ID="ddl_itsstype" runat="server" onChange="selectType(this.value)" datatype="*" nullmsg="请选择申请类型"></asp:DropDownList>--%>
                        <asp:Label id="l_itsstype" runat="server">流程驳回</asp:Label>
                    </td>
                    <th style="width:15%">驳回类型：</th>
                    <td style="width:35%">
                        <asp:DropDownList ID="ddl_itssreason" runat="server" datatype="*" nullmsg="请选择申请类型"></asp:DropDownList>
                        <asp:Label runat="server" ID="l_itssreason"></asp:Label>
                    </td>
                </tr>
            </tbody>
            <tbody id="abortProcess" runat="server">
            <tr>
                <td  class="title">驳回流程列表</td><td colspan="5" style="color:red">驳回流程为全部驳回，不允许单条驳回</td>
            </tr>
            <tr>
                <th>业务流程号：</th>
                <td colspan="3">
                    <input type="hidden" runat="server" id="businesskey"  class="recipient" style="width: 300px"/>
                    <asp:Label runat="server" ID="l_businesskey"></asp:Label>
                </td>
            </tr>
            <tr>
                <td colspan="4">
                    <table class="htable">
                        <thead>
                            <tr>
                                <th style="text-align: center;width:5%">状态</th>
                                <th style="text-align: center; width:10%;">流程名</th>
                                <th style="text-align: center; width:8%;">步骤</th>
                                <th style="text-align: center;">摘要</th>
                                <th style="text-align: center; width:10%;">接收日期</th>
                                <th style="text-align: center; width:10%;">申请人</th>
                                <th style="text-align: center; width:4%;">序号</th>
                            </tr>
                        </thead>
                        <tbody id="tbbusinesskey">
                        </tbody>
                    </table>
                </td>
            </tr>
            </tbody>
            <tbody id="changeDeposit" runat="server">
                <tr>
                    <td colspan="4" class="title">保证金调整列表</td>
                </tr>
                <tr>
                    <td colspan="4">
                        <table class="htable">
                            <tbody>
                                <tr>
                                   <th style="width: 13.33%">经销商编号：</th>
                                    <td style="width: 20%">
                                        <input type="text" runat="server" datatype="*" onblur="showDeposit()" nullmsg="请填写经销编号" id="dealercode" name="dealercode"/>
                                        <asp:Label runat="server" ID="l_dealercode"></asp:Label>
                                    </td>
                                    <th style="width: 13.33%">授权号：</th>
                                    <td style="width: 20%">
                                        <input type="text" runat="server" datatype="*" onblur="showDeposit()" nullmsg="请填写授权号" id="authid" name="authid"/>
                                        <asp:Label runat="server" ID="l_authid"></asp:Label>
                                    </td>
                                    <th style="width: 13.33%">固定资产号：</th>
                                    <td style="width: 20%">
                                        <input type="text" runat="server" datatype="*" onblur="showDeposit()" nullmsg="请填写固定资产号" id="fullsetsn" name="fullsetsn"/>
                                        <asp:Label runat="server" ID="l_fullsetsn"></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                   <th style="width: 13.33%">原保证金：</th>
                                    <td style="width: 20%">
                                        <asp:Label runat="server" name="olddeposit" ID="olddeposit"></asp:Label>
                                        <input type="hidden" runat="server" name="h_olddeposit" id="h_olddeposit"/>
                                    </td>
                                    <th style="width: 13.33%">调整保证金：</th>
                                    <td style="width: 20%" colspan="3">
                                        <input type="text" runat="server" datatype="*" nullmsg="请填写调整后保证金" id="newdeposit" name="newdeposit"/>
                                        <asp:Label runat="server" ID="l_newdeposit"></asp:Label>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                    
                </tr>
                <tr>
                    <td colspan="4">
                    <table class="htable">
                        <thead>
                            <tr>
                                <th style="text-align: center;">经销商编号</th>
                                <th style="text-align: center;">授权号</th>
                                <th style="text-align: center;">固定资产号</th>
                                <th style="text-align: center;">保证金</th>
                            </tr>
                        </thead>
                        <tbody id="tbdepositInfo">
                        </tbody>
                    </table>
                </td>
                </tr>
                <tr>
                    <td colspan="4">
                    <table class="htable">
                        <thead>
                            <tr>
                                <th style="text-align: center;width:5%">操作</th>
                                <th style="text-align: center;width:10%">业务流程号</th>
                                <th style="text-align: center;width:10%">状态</th>
                                <th style="text-align: center;">摘要</th>
                            </tr>
                        </thead>
                        <tbody id="tbbsInfo">
                        </tbody>
                    </table>
                </td>
                </tr>
            </tbody>
            <tbody>
                <tr>
                   <th>申请理由：</th>
                   <td colspan="3">
                       <textarea id="reason" runat="server" name="reason" style="width: 90%;height: 80px" rows="2"></textarea>
                       <asp:Label runat="server" ID="l_reason"></asp:Label>
                   </td>
                </tr>
            </tbody>
                
            <!-- 需要填写的表单、相关附件 st -->
            <tbody>
                <tr>
                    <th>相关附件：</th>
                    <td colspan="3">
                        <uc:ajaxUpload ID="ajaxUpload1" runat="server" />
                    </td>
                </tr>
            </tbody>
            <!-- 需要填写的表单、相关附件 ed -->

            <!-- 审批列表 st -->
            <tbody id="assessment" runat="server" visible="True">
                <tr>
                    <td class="title" colspan="4">审批列表</td>
                </tr>
                <tr>
                    <td colspan="4">
                        <uc:DwzAssessmentList ID="DwzAssessmentList1" runat="server" />
                    </td>
                </tr>
            </tbody>
            <!-- 审批列表 ed -->

            <!-- 审批意见 st -->
            <tbody>
                <uc:DwzAssessment ID="DwzAssessment1" runat="server" />
            </tbody>
            <!-- 审批意见 ed -->
        </table>


    <%  if(H2.NET.Common.AksRequest.GetString("showbtn") != "0")
        { %>
        <div style="margin: 5px; padding-bottom: 10px; text-align: center;">
            <asp:Button ID="btn_submit" runat="server" CssClass="u-btn" Text="提交(Submit)" OnClick="btn_submit_Click" OnClientClick="return confirmSubmit();" />
            <input type="button" class="u-btn u-btn-c4" value="关闭(Close)" onclick="custom_close()" />
            <asp:HyperLink ID="hl_ExportPdf" runat="server" Visible="false" Target="_blank" CssClass="u-btn u-btn-c3" style="height:28px; line-height:28px; display:inline-block;">生成(PDF)</asp:HyperLink>
            <asp:Button ID="btn_print" runat="server" CssClass="u-btn u-btn-c2" Text="打印(Print)" OnClientClick="window.print()" Visible="false" />
        </div>
    <%  } %>
        </form>
    </div>
</body>

</html>